package com.example.friend.controller.user;

import com.example.api.domain.vo.UserQuestionResultVO;
import com.example.common.core.controller.BaseController;
import com.example.common.core.domain.Result;
import com.example.friend.domain.user.dto.UserSubmitDTO;
import com.example.friend.service.user.IUserQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/question")
public class UserQuestionController extends BaseController {

    @Autowired
    private IUserQuestionService userQuestionService;

    //用户提交题目
    @PostMapping("/submit")
    public Result<UserQuestionResultVO> submit(@RequestBody UserSubmitDTO submitDTO) {
        return userQuestionService.submit(submitDTO);
    }

    //用户提交题目，rabbitmq版本
    @PostMapping("/rabbit/submit")
    public Result<Void> rabbitSubmit(@RequestBody UserSubmitDTO submitDTO) {
        return toResult(userQuestionService.rabbitSubmit(submitDTO));
    }

    //获取判题结果
    @GetMapping("/exe/result")
    public Result<UserQuestionResultVO> exeResult(Long examId , Long questionId,String currentTime) {
        return Result.ok(userQuestionService.exeResult(examId,questionId,currentTime));
    }

}
